package com.moresir.validatetools.config;

import com.moresir.validatetools.common.response.ResponseEnum;
import com.moresir.validatetools.exceptions.BusinessException;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

@AllArgsConstructor
public enum ReplaceConstantEnum {
    infoFlag("infoFlag", Arrays.asList(
                    "Y",
                    "N"
            )),
    isSuc("isSuc", Arrays.asList(
            "Y",
            "N"
    ));

    private String k;
    private List v;

    public static String getInPlacePatternValue(String signIn){
        for(ReplaceConstantEnum item : ReplaceConstantEnum.values()){
            if(item.k.equals(signIn)){
                return StringUtils.join(item.v, ',');
            }
        }
        throw new BusinessException(ResponseEnum.VALIDATE_EXCEPTION.getCode(), String.format("入参校验占位符标记：%s不存在", signIn));
    }
}
